package org.br.plotter.functions;

import java.lang.reflect.*;

class MathExecuter implements EmbededFunctionExecuter {
	private Method method;

	public MathExecuter(Method method) {
		this.method = method;
	}

	public double executeFunction(double[] params) {
		try {
			return (Double) method.invoke(null, params);
		} catch (IllegalAccessException iex) {
			FunctionLocator.getExceptionHandler().handleException(iex);
		} catch (InvocationTargetException iv) {
			FunctionLocator.getExceptionHandler().handleException(iv);
		}
		throw new RuntimeException(
				"Error has been occured when executing the method");
	}

}